// phalanx for_each.hpp.cu header file

// Copyright (c) 2010 - 2011 Kohei Takahashi (Flast).
// Distributed under the MIT license. for more detail see COPYING.

// Redefinition C++03 for each algorithm

#ifndef IG_PHALANX_ALGORITHM_FOR_EACH_HPP_CU_ONCE_
#define IG_PHALANX_ALGORITHM_FOR_EACH_HPP_CU_ONCE_

#include <phalanx/config.hpp.cu>

#include <phalanx/utility/begin_end.hpp.cu>

namespace phalanx
{

template < typename Function, typename InputIterator >
PHALANX_CONFIG_DEFAULT_FUNCTION( false )
Function
for_each( InputIterator first, const InputIterator last, Function f )
{
    for ( ; first != last; ++first )
    { f( *first ); }
    return f;
}

template < typename Container, typename Function >
PHALANX_CONFIG_DEFAULT_FUNCTION( false )
Function
for_each( Container &cont, Function f )
{ return for_each< Function & >( begin( cont ), end( cont ), f ); }

template < typename Container, typename Function >
PHALANX_CONFIG_DEFAULT_FUNCTION( false )
Function
for_each( const Container &cont, Function f )
{ return for_each< Function & >( begin( cont ), end( cont ), f ); }

} // namespace phalanx

#endif // IG_PHALANX_ALGORITHM_FOR_EACH_HPP_CU_ONCE_

